﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Models;

namespace DAL
{
    public class D_T
    {

        public bool save_result(List<Models.t_data> ts)
        {
            var count = Sugar_helper.Db.Storageable<t_data>(ts).ExecuteCommand();
            return count==ts.Count? true: false;
        }

        public Models.t_data select(Models.Teacher teacher)
        {
            var t = Sugar_helper.Db.Queryable<t_data>().Where(m_t=> m_t.t_id == teacher.teacher_id).ToList();
            if(t.Count == 0 ) { return null; }

            return t[0];
        }

        public int commit_suger(t_data model)
        {
            var count = Sugar_helper.Db.Storageable(model).ExecuteCommand();
            return count;
        }

        public List<Models.t_data> getList()
        {
            var list = Sugar_helper.Db.Queryable<t_data>().ToList();
            return list;
        }
    }
}
